#include "main.h"

fileHead * _makeFileHead (char * fileName)
{
	char * pos;
	fileHead * fileHd = (fileHead *) calloc (1,sizeof(fileHead));
	struct stat * fileStat = (struct stat * ) calloc (1,sizeof(struct stat));
	int len = 0;
	if (!fileHd)	cl_exit (MAKE_FILE_HEAD,MEMORY_ERR);
	if (!fileStat)	cl_exit (MAKE_FILE_HEAD,MEMORY_ERR);
	pos = getName (fileName);	
	stat (fileName,fileStat);
	len = strlen(pos);
	fileHd->sizeName = (size_t) len;
	fileHd->fileName = (char *) realloc (NULL,sizeof(char)*len);	
	if (!fileHd->fileName)	cl_exit (MAKE_FILE_HEAD,MEMORY_ERR);
	strncpy (fileHd->fileName,pos,len);	
	fileHd->mtime = fileStat->st_mtime;
	fileHd->fileSize = (unsigned long long int) fileStat->st_size;
	if (fileStat->st_size >= UINT_MAX) fileHd->huff_ubits |= LEN_8_B;
	if (fileStat->st_size < 2*1024)	fileHd->huff_ubits |= NO_HUFF;//test revision
	free (fileStat);
	return fileHd;
}
